﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BTS6000
{
    public partial class frmSQL_SaveParameter : Form
    {
        string XML;
        public frmSQL_SaveParameter(string xml)
        {
            InitializeComponent();

            XML = xml;
            txtOutput.Text = XML;
        }

        private void frmSQL_SaveParameter_Load(object sender, EventArgs e)
        {
            this.Icon = Properties.Resources.Tools;
            Language.ToCHT(this);
        }

        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                if(string.IsNullOrEmpty(txtModel.Text))
                {
                    MessageBox.Show(Program.MDI.SR.DataCanNotBeBlank, lblModel.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if(string.IsNullOrEmpty(XML))
                {
                    MessageBox.Show(Program.MDI.SR.DataCanNotBeBlank, "Parameter", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if(SQL.Instance.AppendParameter("TP_6000_Plus_Parameter", txtModel.Text, txtNote.Text, XML))
                {
                    MessageBox.Show(Program.MDI.SR.OperationDone, Program.MDI.SR.Message, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Program.MDI.SR.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
